{extend name="public/base" /} {block name="body"}
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('web/index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li>
			<strong>库存管理</strong>
		</li>
	</ol>
</div>
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<form id="myForm" class="form-horizontal" method="post" action="{:url('manage')}">	
			<div class="form-group" style="padding-left: 20px;">
					商品名称 <input type="text" id="goods_name" name="goods_name" value="" placeholder="请输入商品名称" class="bank" />
	     			<select name="goods_typeid" class="bank" id="goods_typeid">
								<option value="a">请选择商品分类</option>
								{volist name="storeGoodsType_list" id="vo"}
									<option value="{$vo.id}" >{$vo.name}		
									</option>
								{/volist}								
							</select>
	     		 	<select  name="status" class="bank" >
                        <option value="0">库存状态</option>
                        <option value="1">库存充足</option>
                        <option value="2">库存预警</option>
                    </select>
					<span class="bank"><button type="submit" class="btn btn-sm btn-primary"><li class="fa fa-search"> 查询</li></button> </span>
			</div>
		</from>
		<div class="hr-line-dashed"></div>
            <div class="example-wrap">
				<div class="example">				
					<table class="table table-bordered table-hover">
						<thead>
							<tr class="long-th">    
                            	<th>商品名称</th>
                                <th>商品分类</th>
                                <th>库存预警值</th>
                                <th>库存</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list" style="text-align: center;">
                        	{volist name="list" id="vo"}
                        	   <tr>
                        	   	<td>{$vo.goods_name}</td>
                        	   	<td>{$vo.name}</td>
                        	   	<td>{$vo.stock_warning}&nbsp;
                    	   			<a name="set-stock-warn"  id="yjsz"  class="fa fa-pencil" title="设置库存预警值" onclick="kcyj('{$vo.goods_name}','{$vo.id}','{$vo.stock_warning}')"></a>
                        	   	</td>
                        	   	<td>{$vo.stock}&nbsp;
                        	   	<a name="set-stock-warn"  id="kcgl"  class="fa fa-pencil" title="设置库存" onclick="kcgl('{$vo.goods_name}','{$vo.id}','{$vo.stock_warning}')"></a></td>
                        	   	<td>                        	   		
									<a href="{:url('detail',['id'=>$vo.id])}" class="btn btn-primary bnt-sm">
										<i class="fa fa-paste"></i> 明细</a>                	   		
                        	   	</td>
                        	   </tr>
                        	{/volist}
                        </tbody>
                    </table>
                    <div style="text-align: right;">
                    </div>
                </div>
            </div>
            </div>
</div>
{/block} {block name="script"}
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>

</script>
<script>	
	function kcyj(name,id,stock_warning){
		
		var html = '<div class="input-group m-b" style="width:100%;text-align: center;">'+
		            '</div>'+
					'<table class="table table-bordered table-hover">'+
						'<thead>'+
							'<tr class="long-th">'+
								'<th >商品名称</th>'+
								'<th >库存警告值</th>'+
							'</tr>'+
							'<tr class="long-th" style="text-align: center;">'+
								'<td>'+name+'</td>'+
								'<td class="text-center"><input type="text" id="stock_warning" value="'+stock_warning+'" class="form-control" /></td>'+
							'</tr>'+							
						'</thead>'+
					'</table>';
		var index=layer.open({			
			  title: '设置库存预警值',
			  zIndex :"addjb",
		 	  area: ['550px', '250px'] ,
			  content: html,
			  btn: ['确定','取消'],
			  yes: function(index, layero){
			    //按钮【按钮一】的回调
			    	$.ajax({
						url:'saveyj',
						data:{id:id,stock_warning:$("#stock_warning").val()},
						type:"post",
						success: function(data) {
							layer.msg(data.msg);
							layer.close(index);
							window.location.reload();
						}
					})
			  },btn2:function(index,layero){
			  		layer.close(index);
			  }
			});
	}
	
	//库存操作
	function kcgl(name,id,stock){
		
		var html = '<div class="input-group m-b" style="width:100%;text-align: center;">'+
						'<a onclick="instock(&quot;'+name+'&quot;,'+id+','+stock+')" class="btn btn-primary btn-outline">商品入库</a>&nbsp;&nbsp;'+
						'<a onclick="outstock(&quot;'+name+'&quot;,'+id+','+stock+')" class="btn btn-primary btn-outline">商品出库</a>'+
		            '</div>';
		var index=layer.open({			
			  title: '选择出入库',
		 	  area: ['300px', '150px'] ,
			  content: html,
			  btn: false
			});
	}
	
	//入库操作
	function instock(name,id,stock){
		layer.open({		
	  	type: 2, 
	  	id: "stockoper",
	 	area: ['850px', '450px'] ,
	 	title: '制作入库单',
	 	scrollbar: false,
	  	content: '/web/stock/stockoper?type=1&id='+id+'&name='+name+'&stock='+stock //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		}); 
	}
	
	//入库操作
	function outstock(name,id,stock){
		layer.open({		
	  	type: 2, 
	  	id: "stockoper",
	 	area: ['850px', '450px'] ,
	 	title: '制作出库单',
	 	scrollbar: false,
	  	content: '/web/stock/stockoper?type=2&id='+id+'&name='+name+'&stock='+stock //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		}); 
	}
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    text-align:center;
    border-radius:5px;
}
</style>
{/block}